from django.shortcuts import render
from django.http import JsonResponse
from detail.models import GradeDetail
# 返回chart/的url
def chart_list(request):
    """数据统计页面"""
    return render(request,"chart.html")

# 柱状图的url
def chart_bar(request):
    """构造柱状图的数据"""
    legend = ['赵小虎','黄鹏飞']
    series_list = [
            {
                "name" : '赵小虎',
                "type" : 'bar',
                "data" : [85, 56, 66, 90, 80, 74],
                "color" : 'rgb(0, 123, 255)'
            },
            {
                "name" : '黄鹏飞',
                "type" : 'bar',
                "data" : [90, 56, 76, 60, 40, 73],
                "color" : 'rgb(130, 197, 105)'
            }
    ]
    x_axis = ["高数","英语","C语言","JAVA","Python","政治"]

    result = {
        "status":True,
        "data":{
            'legend':legend,
            'series_list':series_list,
            'x_axis':x_axis,
        }
    }
    return JsonResponse(result)

# 折线图的url
def chart_line(request):
    """构造柱状图的数据"""
    legend = ['张欣','朱旭驲','李锦强']

    series_list = [
        {
            "name" : '张欣',
            "type" : 'line',
            "data" : [90, 82, 78, 92, 71, 82],
            "color" : 'rgb(21,101,192)'
        },
        {
            "name" : '朱旭驲',
            "type" : 'line',
            "data" : [72, 56, 64, 90, 83, 67],
            "color" : "rgb(204,119,34)"
        },
        {
            "name" : '李锦强',
            "type" : 'line',
            "data" : [78, 49, 67, 83, 26, 39],
            "color" : "rgb(87,196,15)"
        }
    ]
    x_axis = ["高数","英语","C语言","JAVA","Python","政治"]

    result = {
        "status":True,
        "data":{
            'legend':legend,
            'series_list':series_list,
            'x_axis':x_axis,
        }
    }
    return JsonResponse(result)